/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2021-12-11 17:19:51
 * @LastEditors: Clark
 * @LastEditTime: 2021-12-11 18:05:58
 * @Description: file content
 */

#ifndef XML_FILE
#define XML_FILE

#include <string>
#include "tinyxml2.h"
#include "user.h"

#define XML_FILE_NAME "letstalk.xml"

class XmlFile
{
public:
    XmlFile(std::string &fileName);

    bool init();

    bool add_user(User &user);

    bool delete_user(User &user);

    bool select_user(User &user);

    bool change_user(User &user);

    unsigned int get_user_count();

    bool get_user_by_index(unsigned int index, User &user);

    bool save_file();

    ~XmlFile();

private:
    tinyxml2::XMLDocument *doc;
    std::string fileName;
};

#endif
